package com.smz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smz.entity.TPar;
import com.smz.service.TParService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ParController {

    @Autowired
    TParService tParService;

    @PostMapping("/par/{sid}")
    public ResponseEntity<String> addPar(@PathVariable("sid")int sid){
        return ResponseEntity.ok(tParService.addTPar(sid));
    }
    //本公司申请
    @GetMapping("/pars/{current}/{size}")
    public ResponseEntity<IPage<TPar>> findParA(@PathVariable("current")int current, @PathVariable("size")int size){
        return ResponseEntity.ok(tParService.findTParByA(current,size));
    }
    //需要处理的申请
    @GetMapping("/par/{current}/{size}")
    public ResponseEntity<IPage<TPar>> findParB(@PathVariable("current")int current, @PathVariable("size")int size){
        return ResponseEntity.ok(tParService.findTParByB(current,size));
    }
    //时间查询
    @GetMapping("/par/{current}/{size}/{time1}/{time2}")
    public ResponseEntity<IPage<TPar>> findParTime(@PathVariable("current")int current, @PathVariable("size")int size,
                                                   @PathVariable("time1")String time1, @PathVariable("time2")String time2){
        return ResponseEntity.ok(tParService.findTParByTime(current,size,time1,time2));
    }
    //查询所有
    @GetMapping("/pars/all/{current}/{size}")
    public ResponseEntity<IPage<TPar>> findParAll(@PathVariable("current")int current, @PathVariable("size")int size){
        return ResponseEntity.ok(tParService.findAll(current,size));
    }
}
